A Rational Software Architect RealTime Edition (RSARTE) model contains snippets of code in many places where actions and expressions can be specified. There are four ways in which such code snippets can be edited:
Using the code view.
The code view is mainly intended to be used for viewing code snippets and to make small modifications to them. The code view can only show one code snippet at a time and you can only have one code view open.
Using the code editor.
The code editor is recommended for general editing of code snippets. You can have multiple code editors open at the same time and all common benefits with Eclipse editors also apply for code editors.
Using an internal Eclipse source editor (for C++ this is the CDT editor).
You can use this editor after you have transformed your model into C++ code. The CDT editor shows a generated C++ file in its entirety and this file might contain multiple code snippets. The code snippets are enclosed within USR comment blocks. Here is an example of what it might look like:
//{{{USR platform:/resource/Sample/HelloWorld.emx#_ZT0WMI7mEeG--Krzx7QXSQ
log.show("Hi!");
//}}}USR
A benefit of editing code snippets in the CDT editor is that you can see the full context where the code snippet is located. This might make it easier to understand the code, than when just looking at the code snippet in isolation (as you do with the code view and code editor).
Using an external text editor.
Using an external text editor is like using an internal Eclipse source editor, except that you choose another external editor instead. Using an external text editor is more error prone when it comes to code-to-model synchronization and is therefore not recommended.
When editing a code snippet using the code view or code editor, keep the following in mind:
The edited code snippet can either be located in the model or it can be located in a generated file. Pay attention to the text that is shown in the header of the code view or code editor:

In the former case, the code snippet is located in the model.
In the latter case, the code snippet is located in a generated file.
When editing a code snippet located in the model, certain features of the code view or code editor are not available or work differently. For example, all editor features that require a complete C++ file, such as Open Declaration, Open Type Hierarchy, and so forth, are not available. Features like code completion are limited to finding only those elements that are defined in the model (for example, you only get basic content assist; see Content assist).
When editing a code snippet located in a generated file, the code view or editor actually edits the generated file, although it only shows one particular code snippet of that file. All CDT editor features are available when the code view or editor operates in this mode.
Usually, you want the code view or editor to edit a code snippet located in a generated file, since all editor features are available and fully functional. However, there are cases when this is not possible:
If the code snippet cannot be found in the generated file: for example, if you add a new operation to an existing class, its body code snippet does not appear in the generated file until the next time the model is transformed to C++.
By default, the code view or editor tries to locate a generated file for a code snippet as soon as it gets focus. This behavior is controlled by a preference (UML Development - Real Time - Auto load generated source when focus gained). It is recommended that you do not turn off this preference.
However, even if this preference is enabled, there are cases when the generated file cannot be automatically loaded. So, if you find that a code snippet that you are about to edit is located in the model, it is recommended to try and manually load the generated file so that the code view or editor edits the code snippet stored in the generated file. To manually load the generated file, invoke the command Load Generated Source, which is available in the context menu of the code view or editor .
If the loading of the generated file fails (for reasons mentioned previously), you have no other choice than to edit the code snippet located in the model.
When you edit a code snippet (or multiple code snippets) using an external or internal source editor (such as the CDT editor), keep the following in mind:
Do not make any modifications that are not within a code snippet (for example, do not change something outside of a USR comment block). Such modifications are lost the next time the file is regenerated. Also, such modifications might cause failure of the code-to-model synchronization, which means that you might also lose changes made within code snippets.
Do not make changes to the lines that start or end a USR comment block. Such changes might cause code-to-model synchronization to fail.
When you have modified one or multiple code snippets in a generated file, save the file before leaving the CDT editor. If you do not save, and instead perform an operation that might indirectly alter the file you just modified (such as a refactoring, or C++ code generation), RSARTE usually detects that the file has not been saved and opens a warning dialog where you can save the editor. Always accept to save the file to avoid losing changes. There are some operations where RSARTE cannot open the warning dialog. It is good to be proactive and not rely on this mechanism. The recommendation is to save a modified CDT editor before you start doing something else.
When you save a generated file in which you have modified at least one code snippet, expect to see a dialog "Code To Model Synchronization." If you do not see the dialog, something has gone wrong and RSARTE failed to detect the changes you made. In this case, copy the changes you made to a different text editor, close all editors in RSARTE, and regenerate the file by transforming the model to C++ again. After transforming the file, you can open the CDT editor and reintroduce the changes to the code snippets. Save the file to trigger the code-to-model synchronization.
Review the changed code snippets in the Code To Model Synchronization dialog before pressing the Commit button. By reviewing the code snippets, you have a chance to detect if the changes you have made to the code snippets in the generated file will overwrite other changes you have made to those code snippets that are stored in the model (this should not happen unless you have enabled the preference UML Development - Code To Model Synchronization - Allow modified code snippets in the model to be overwritten by unmodified code snippets from the file). To review a code snippet, double-click it in the Structure Compare area. Here is an example of how the dialog might look:

The code in the Old Source view shows the code snippet as stored in the model. The New Source view shows the modified code snippet that is committed to the model when you click Commit.
If you do not want to commit some of the updated code snippets, you can deselect the checkbox for that code snippet before clicking Commit.
If you press Cancel, no code snippets are updated, and all changes are lost the next time the file is regenerated.
To summarize the most important recommendations mentioned above:
When you have modified one or multiple code snippets in a generated file, save the file before you leave the CDT editor. The same recommendation applies when using the code editor.
Never make changes outside a code snippet in a generated file.
Whenever possible, edit code snippets from generated files rather than from the model. This ensures you have the full CDT editing capabilities available.
Review code snippet modifications when the Code To Model Synchronization dialog appears.